<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body {
            width: 50%;
            height: 100vh;
            margin: 0 auto;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        .main {
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        p:not(.p2) {
            /* 样式作用于除了p2类以外的所有p元素 */
            color: red;
        }
    </style>
</head>

<body>
    <div class="main">
        <p>p1</p>
        <p class="p2">p2</p>
        <p class="p3">p3</p>
        <p>p4</p>
        <p>p5</p>
    </div>
</body>

</html>